<%@ Page Title="SacNetUg Event Reminder" Language="C#" MasterPageFile="~/Views/Shared/Blank.Master"
    Inherits="System.Web.Mvc.ViewPage<SacNetUG.Models.Event>" %>

<%@ Import Namespace="SacNetUG.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    SacNetUg Event Reminder
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        body
        {
            background-color: #FFFFFF;
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: x-small;
            margin-left: 0px;
            margin-right: 0px;
        }
        .h1
        {
            font-family: Verdana, Arial, Helvetica, sans-serif;
            font-size: small;
            font-weight: bold;
            padding-bottom: 0px;
        }
        .bodyTable
        {
            font-size: x-small;
            width: 600px;
            text-align: left;
            padding: 2px;
            vertical-align: top;
        }
        .bodyTable td
        {
            font-size: x-small;
            vertical-align: top;
        }
        .title
        {
            font-size: small;
        }
    </style>
    <!--
    if there is an event sponsor, list here, other wise always use QUEST ID 12
    -->
    <%
        var eventSponsorIds = new int[] {12};
        if (Model.EventSponsors.Count > 0)
            eventSponsorIds = Model.EventSponsors.Select(p => p.SponsorId).ToArray();


        var db = new SacNetUGDataContext();
        var eventSponsors =
            db.EventSponsors.Where(p => eventSponsorIds.Contains(p.SponsorId) & p.EventId == Model.EventId);
        
        //use the first sponsor as the image
        var firstSponsor = eventSponsors.FirstOrDefault();

        var sponsor = firstSponsor == null ? db.Sponsors.Where(p => p.SponsorId == 12).FirstOrDefault() : firstSponsor.Sponsor;
            

        var presenterNames = Model.EventPresenters.Aggregate("",
                                                             (current, eventPresenter) =>
                                                             current + (eventPresenter.User.Name + ", "));
%>
    <table width="592px" class="bodyTable">
        <tr>
            <td>
                <table width="100%"cellpadding="2" cellspacing="2">
                    <tr>
                        <td colspan="2">
                            <div>
                                <table cellspacing="2" cellpadding="2" width="100%"border="0">
                                    <tr>
                                        <td width="33%" align="left">
                                                <a href="http://www.sacnetug.org">
                                                    <img src="http://www.sacnetug.org/images/SacDnug.gif" border="0">
                                                </a>
                                        </td>
                                        <td align="right" width="33%">
                                        </td>
                                        <td align="right" width="33%">
                                        <a href="<%=sponsor.Url%>">
                                                    <img src="<%=sponsor.LogoUrl%>" border="0">
                                                </a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4">
                                            <hr size="1" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4" align="center">
                                            <span class="title"><strong>
                                                <!--LOG DATE-->
                                                <%:Model.StartDate.ToLongDateString()%>:
                                                <%=presenterNames%><br />
                                                <%:Model.Name%><!--TITLE--></strong></span>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>When: </strong>
                        </td>
                        <td>
                                <%:string.Format("{0:MMM dd, yyyy}", Model.StartDate)%>
                                from 6:00 to 8.30 PM
                        </td>
                    </tr>
                    <tr>
                        <td>
                                <strong>RSVP</strong>:
                        </td>
                        <td>
                                Seating based on availability. - <strong>RSVP Recommended</strong>.<br />
                                Please RSVP at <a href="http://www.sacnetug.org/event/rsvp" title="RSVP">http://www.sacnetug.org/event/rsvp</a>
                                (login required)
                        </td>
                    </tr>
                    <tr>
                        <td>
                                <strong>Where</strong>:
                        </td>
                        <td>
                                UC Davis Extension, <strong>Room 200A</strong>, Sacramento.<br />
                                Sutter Square Galleria, 2901 K St., Sacramento, CA 95816
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Directions:</strong>
                        </td>
                        <td>
                            2901 K St. is between 29th and 30th and K&amp;J Streets (<a href="http://extension.ucdavis.edu/facilities/galleria_map.asp"
                                target="_blank">Map &amp; Directions</a>)
                            <br />
                            <strong>Business I-80 northbound:&nbsp;</strong>Take the N Street exit. Continue
                            north on 30th Street for three blocks and turn left on K Street. Turn right into
                            the parking garage.<br />
                            <strong>Business I-80 southbound:&nbsp;</strong>Take the J Street exit. At the first
                            stoplight (immediately after the exit), turn left on J Street. Turn right into the
                            parking garage.
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                                <strong>Speakers</strong>:
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%
        foreach (var presenter in Model.EventPresenters)
        {
            if (!string.IsNullOrEmpty(presenter.User.ImageUrl))
            {%>
                            <%=Html.Image(presenter.User.ImageUrl, presenter.User.Name)%>
                            <%
            }
        }%>
                        </td>
                        <td>
                            <%
        foreach (var presenter in Model.EventPresenters)
        {
            if (!string.IsNullOrEmpty(presenter.User.Bio))
            {%>
                            <%=presenter.User.Bio%>
                            <%
            }
        }%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Topic:</strong>
                        </td>
                        <td>
                            <strong>
                                <%:Model.Name%></strong>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <%=Model.Description%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Sponsors</strong>
                        </td>
                        <td>
                        <%
                            if (Model.EventSponsors.Count > 0)
                            {%>
                            <strong>Event Sponsors</strong>
                            <%
                            foreach (var spon in eventSponsors)
                            {
%>
                            <p>
                                <strong>
                                    <%:spon.Sponsor.Name%></strong><br />
                                <%=spon.Blurb%></p>
                            <%
                            }%>
                        </td>
                        <%
                            }
                            else
                            {%><%
                                Html.RenderPartial("ReminderOtherSponsors");%><%
                            }%>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
    <%if (Model.EventSponsors.Count > 0)
      {%><%
          Html.RenderPartial("ReminderOtherSponsors");%><%
      }%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <strong>Fees</strong>
                        </td>
                        <td>
                            <strong>Admission is free. </strong>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <font size="-2">This email is sent to only registered members with a username and password.
                                If you do not like to receive event announcements in future, please login and change
                                your email options</font>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>
